package day11.Exer;

public class Teacher  {
    private String name;
    private String school;
    private int age;

    public Teacher(String name, String school, int age) throws Exception {
        if(age<22){
            throw new Exception("年龄太小");
        }
        this.name = name;
        this.school = school;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSchool() {
        return school;
    }

    public void setSchool(String school) {
        this.school = school;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws Exception {
        this.age = age;
        if(age<22){
            throw new Exception("年龄太小");
        }
    }
    public void introductSelf(){
        System.out.println("老师的名字是"+name+",来自"+school+"这个学校，今年"+getAge()+"岁。");
    }
    public void giveLesson(){
        System.out.println("老师给学生上课。");
    }
}
